package com.aiwei.tdjk.service.impl;

import com.aiwei.tdjk.dao.mbg.RoleResourcePermissionMapper;
import com.aiwei.tdjk.entity.RoleResourcePermission;
import com.aiwei.tdjk.entity.RoleResourcePermissionExample;
import com.aiwei.tdjk.service.RoleResourcePermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by yanfeng on 2016/12/26.
 */
@Service
public class RoleResourcePermissionServiceImpl implements RoleResourcePermissionService {

    @Autowired
    private RoleResourcePermissionMapper roleResourcePermissionMapper;

    @Override
    public void save(RoleResourcePermission roleResourcePermission) {
        roleResourcePermissionMapper.insertSelective(roleResourcePermission);
    }



    @Override
    public int delete(Long id) {
        return 0;
    }

    @Override
    public int delete(Long[] ids) {
        return 0;
    }

    @Override
    public List<RoleResourcePermission> getResourcePermissionsByRoleId(Long id) {
        RoleResourcePermissionExample example = new RoleResourcePermissionExample();
        example.or().andRoleIdEqualTo(id);
        return roleResourcePermissionMapper.selectByExample(example);
    }

    @Override
    public int deleteResourcePermissionsByRoleId(Long id) {
        RoleResourcePermissionExample example = new RoleResourcePermissionExample();
        example.or().andRoleIdEqualTo(id);
        return roleResourcePermissionMapper.deleteByExample(example);
    }
}
